-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF: Base class for all extension tests #19863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Added the staticmethods - assert_series_equal - assert_frame_equal to the base class. Useful for test cases like DecimalArray with NaNs, since our assert_*_equal methods don't properly handle Decimal NaNs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we advertising this kind of api for testing? when we always use tm.assert_*
? this is too easy to get wrong. wouldn't it be better to use that as the main one (e.g. make them EA aware)?
@@ -4,8 +4,10 @@ | |||
import pandas.util.testing as tm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we don't / shouldn't import tm
in any of the subclasses of EA for testing (otherwise easy to accidently NOT use self.assert_*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still used for things like assert_raises_regex
. But maybe we could import them explicitly (from pandas.util.testing import ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
|
||
All the tests in these modules use ``self.assert_frame_equal`` or | ||
``self.assert_series_equal`` for dataframe or series comparisons. By default, | ||
they use the usual ``pandas.util.testing.assert_frame_equal`` and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pandas.util.testing.assert_frame_equal -> pandas.testing.assert_frame_equal (that is the public API path)
@@ -4,8 +4,10 @@ | |||
import pandas.util.testing as tm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still used for things like assert_raises_regex
. But maybe we could import them explicitly (from pandas.util.testing import ...
I thought about doing that for the test cases we've written. Decimal('NaN') is the problem I've hit since we don't compare NaNs "correctly". But I don't think it'd be worthwhile putting in fixes for those specific ones since, 1.) It's only solving the problem for our specific functions. 3rd party libraries writing EAs would have no way to fix it.
Yes, this is going to be a problem going forward. I'm not sure how best to avoid it, but avoiding a |
I could also add a linting rule that looks for Edit: ahh that may be hard since in a followup I define |
It's only for testing extension arrays (so for developers), not public API for users. Although, one alternative would be to define a |
And then just call |
I am only not sure I am fully convinced myself :). The problem with and |
I think following the lead of That said, I should be able to add a linting rule that looks for |
Codecov Report
@@ Coverage Diff @@
## master #19863 +/- ##
=========================================
Coverage ? 91.64%
=========================================
Files ? 150
Lines ? 48946
Branches ? 0
=========================================
Hits ? 44858
Misses ? 4088
Partials ? 0
Continue to review full report at Codecov.
|
OK, this should now fail if tests in |
But, |
But for this PR, I would personally for now do like you did here. We can later still discuss if we want an |
thanks! |
Added the staticmethods
to the base class. Useful for test cases like DecimalArray with NaNs,
since our assert_*_equal methods don't properly handle Decimal NaNs.
git diff upstream/master -u -- "*.py" | flake8 --diff